//队伍提交flag面板
import { Button, Input, Row, Col, Card, message } from 'antd';
import { useIntl } from 'umi'
import { useState } from 'react'
import { commitFlag } from '@/services/flag';
import styles from './index.less'
const TeamCommitFlagPanel = () => {
    const intl = useIntl();
    const [flag, setFlag] = useState();
    const [confirmLoading, setConfirmLoading] = useState(false)
    const handleCommitFlag = () => {
        setConfirmLoading(true)
        commitFlag({
            flag: flag
        }).then(res => {
            setConfirmLoading(false)
            if (res.success) {
                message.success("提交成功!")
            }
        }).catch(err => {
            setConfirmLoading(false)
        })

    }
    return (
        <div>
            <Card>
                <Row gutter={8} className={styles.commitFlagBox}>
                    <Col span={16}><Input placeholder="请输入flag" onChange={(e) => { setFlag(e.target.value) }} onPressEnter={handleCommitFlag} /></Col>
                    <Col span={8}><Button type="primary" loading={confirmLoading} onClick={handleCommitFlag} >{intl.formatMessage({
                        id: 'component.button.submit',
                    })}</Button></Col>
                </Row>
            </Card>
        </div>
    )
}
export default TeamCommitFlagPanel;